﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace Hxsoft.AppV1.Module
{
	public partial class SystemInit
	{
		/// <summary>
		/// 资源代码。
		/// </summary>
		internal const string ResourceCode = "SystemInit";

		/// <summary>
		/// 资源标识。
		/// </summary>
		internal readonly static Guid ResourceId = new Guid("149012EF-4AAE-493C-988F-40E45F6356A0");

		/// <summary>
		/// 资源名称。
		/// </summary>
		internal const string ResourceName = "系统初始化";

		/// <summary>
		/// 资源描述。
		/// </summary>
		internal const string ResourceDescription = "";

		/// <summary>
		/// 权限码
		/// </summary>
		internal enum PermissionCode
		{
			Init = 1
		}

		/// <summary>
		/// 注册权限。
		/// </summary>
		internal static void RegisterPermissions()
		{
			ResourceCategories.RegisterSystemManage();
			RegisterCategoryResource();
			RegisterResourcePermissions();
		}

		/// <summary>
		/// 注册资源类别下的资源。
		/// </summary>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterCategoryResource()
		{
			Resource resource = new Resource();
			resource.CategoryId = ResourceCategories.SystemManageResourceCategoryId;
			resource.ResourceId = ResourceId;
			resource.ResourceCode = ResourceCode;
			resource.ResourceName = ResourceName;
			resource.Description = ResourceDescription;

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册资源下的权限。
		/// </summary>
		private static void RegisterResourcePermissions()
		{
			Permission permission;

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Init;
			permission.PermissionName = "初始化";
			permission.Description = "";
			Permissions.Register(permission);
		}
	}

	public static partial class Roles
	{
		/// <summary>
		/// 资源代码。
		/// </summary>
		internal const string ResourceCode = "RoleManage";

		/// <summary>
		/// 资源标识。
		/// </summary>
		internal readonly static Guid ResourceId = new Guid("A4442EBC-80EB-46A8-B57F-DDC40D07E95D");

		/// <summary>
		/// 资源名称。
		/// </summary>
		internal const string ResourceName = "角色管理";

		/// <summary>
		/// 资源描述。
		/// </summary>
		internal const string ResourceDescription = "";

		/// <summary>
		/// 权限码
		/// </summary>
		internal enum PermissionCode
		{
			Create = 1,
			Accredit = 2,
			Delete = 15
		}

		/// <summary>
		/// 注册权限。
		/// </summary>
		internal static void RegisterPermissions()
		{
			ResourceCategories.RegisterSystemManage();
			RegisterCategoryResource();
			RegisterResourcePermissions();
		}

		/// <summary>
		/// 注册资源类别下的资源。
		/// </summary>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterCategoryResource()
		{
			Resource resource = new Resource();
			resource.CategoryId = ResourceCategories.SystemManageResourceCategoryId;
			resource.ResourceId = ResourceId;
			resource.ResourceCode = ResourceCode;
			resource.ResourceName = ResourceName;
			resource.Description = ResourceDescription;

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册资源下的权限。
		/// </summary>
		private static void RegisterResourcePermissions()
		{
			Permission permission;

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Create;
			permission.PermissionName = "创建";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Accredit;
			permission.PermissionName = "授权";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Delete;
			permission.PermissionName = "删除";
			permission.Description = "";
			Permissions.Register(permission);
		}
	}
	
	public static partial class Users
	{
		/// <summary>
		/// 资源代码。
		/// </summary>
		internal const string ResourceCode = "UserManage";

		/// <summary>
		/// 资源标识。
		/// </summary>
		internal readonly static Guid ResourceId = new Guid("F0E3A452-0EDF-4606-8B1B-CAE3720D739A");

		/// <summary>
		/// 资源名称。
		/// </summary>
		internal const string ResourceName = "用户管理";

		/// <summary>
		/// 资源描述。
		/// </summary>
		internal const string ResourceDescription = "";

		/// <summary>
		/// 权限码
		/// </summary>
		public enum PermissionCode
		{
			Create = 3,
			Update = 7,
			Delete = 15,
			Setting = 31,
			AdvSetting=63,
			Register = 1024,
			Login = 2048
		}

		/// <summary>
		/// 注册权限。
		/// </summary>
		internal static void RegisterPermissions()
		{
			ResourceCategories.RegisterSystemManage();
			RegisterCategoryResource();
			RegisterResourcePermissions();
		}

		/// <summary>
		/// 注册资源类别下的资源。
		/// </summary>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterCategoryResource()
		{
			Resource resource = new Resource();
			resource.CategoryId = ResourceCategories.SystemManageResourceCategoryId;
			resource.ResourceId = ResourceId;
			resource.ResourceCode = ResourceCode;
			resource.ResourceName = ResourceName;
			resource.Description = ResourceDescription;

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册资源下的权限。
		/// </summary>
		private static void RegisterResourcePermissions()
		{
			Permission permission;

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Create;
			permission.PermissionName = "创建";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Update;
			permission.PermissionName = "修改";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Delete;
			permission.PermissionName = "删除";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Setting;
			permission.PermissionName = "设置";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.AdvSetting;
			permission.PermissionName = "高级设置";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Register;
			permission.PermissionName = "注册";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Login;
			permission.PermissionName = "登录";
			permission.Description = "";
			Permissions.Register(permission);
		}
	}
	
	public static partial class DicClasses
	{
		/// <summary>
		/// 资源代码。
		/// </summary>
		internal const string ResourceCode = "DicClassManage";

		/// <summary>
		/// 资源标识。
		/// </summary>
		internal readonly static Guid ResourceId = new Guid("471BE423-8D55-4769-90C2-8C0055CA0672");

		/// <summary>
		/// 资源名称。
		/// </summary>
		internal const string ResourceName = "字典类别管理";

		/// <summary>
		/// 资源描述。
		/// </summary>
		internal const string ResourceDescription = "";

		/// <summary>
		/// 权限码
		/// </summary>
		public enum PermissionCode
		{
			Insert = 3,
			Update = 7,
			Delete = 15,
		}

		/// <summary>
		/// 注册权限。
		/// </summary>
		internal static void RegisterPermissions()
		{
			ResourceCategories.RegisterSystemManage();
			RegisterCategoryResource();
			RegisterResourcePermissions();
		}

		/// <summary>
		/// 注册资源类别下的资源。
		/// </summary>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterCategoryResource()
		{
			Resource resource = new Resource();
			resource.CategoryId = ResourceCategories.SystemManageResourceCategoryId;
			resource.ResourceId = ResourceId;
			resource.ResourceCode = ResourceCode;
			resource.ResourceName = ResourceName;
			resource.Description = ResourceDescription;

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册资源下的权限。
		/// </summary>
		private static void RegisterResourcePermissions()
		{
			Permission permission;

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Insert;
			permission.PermissionName = "添加";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Update;
			permission.PermissionName = "修改";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Delete;
			permission.PermissionName = "删除";
			permission.Description = "";
			Permissions.Register(permission);
		}
	}
	
	public static partial class InfoItems
	{
		/// <summary>
		/// 资源代码。
		/// </summary>
		internal const string ResourceCode = "InfoItemManage";

		/// <summary>
		/// 资源标识。
		/// </summary>
		internal readonly static Guid ResourceId = new Guid("46B1C13E-EE38-4FE3-8233-F1554CC84C95");

		/// <summary>
		/// 资源名称。
		/// </summary>
		internal const string ResourceName = "信息资源管理";

		/// <summary>
		/// 资源描述。
		/// </summary>
		internal const string ResourceDescription = "";

		/// <summary>
		/// 权限码
		/// </summary>
		public enum PermissionCode
		{
			Delete = 15
		}

		/// <summary>
		/// 注册权限。
		/// </summary>
		internal static void RegisterPermissions()
		{
			ResourceCategories.RegisterSystemManage();
			RegisterCategoryResource();
			RegisterResourcePermissions();
		}

		/// <summary>
		/// 注册资源类别下的资源。
		/// </summary>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterCategoryResource()
		{
			Resource resource = new Resource();
			resource.CategoryId = ResourceCategories.SystemManageResourceCategoryId;
			resource.ResourceId = ResourceId;
			resource.ResourceCode = ResourceCode;
			resource.ResourceName = ResourceName;
			resource.Description = ResourceDescription;

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册资源下的权限。
		/// </summary>
		private static void RegisterResourcePermissions()
		{
			Permission permission;

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Delete;
			permission.PermissionName = "删除";
			permission.Description = "";
			Permissions.Register(permission);
		}
	}
	
	public static partial class InfoResources
	{
		/// <summary>
		/// 资源代码。
		/// </summary>
		internal const string ResourceCode = "InfoResourceManage";

		/// <summary>
		/// 资源标识。
		/// </summary>
		internal readonly static Guid ResourceId = new Guid("FD4E921C-8DB8-451E-BA77-643CE7A383D8");

		/// <summary>
		/// 资源名称。
		/// </summary>
		internal const string ResourceName = "信息资源项管理";

		/// <summary>
		/// 资源描述。
		/// </summary>
		internal const string ResourceDescription = "";

		/// <summary>
		/// 权限码
		/// </summary>
		public enum PermissionCode
		{
			Insert = 3,
			Delete = 15
		}

		/// <summary>
		/// 注册权限。
		/// </summary>
		internal static void RegisterPermissions()
		{
			ResourceCategories.RegisterSystemManage();
			RegisterCategoryResource();
			RegisterResourcePermissions();
		}

		/// <summary>
		/// 注册资源类别下的资源。
		/// </summary>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterCategoryResource()
		{
			Resource resource = new Resource();
			resource.CategoryId = ResourceCategories.SystemManageResourceCategoryId;
			resource.ResourceId = ResourceId;
			resource.ResourceCode = ResourceCode;
			resource.ResourceName = ResourceName;
			resource.Description = ResourceDescription;

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册资源下的权限。
		/// </summary>
		private static void RegisterResourcePermissions()
		{
			Permission permission;

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Insert;
			permission.PermissionName = "添加";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Delete;
			permission.PermissionName = "删除";
			permission.Description = "";
			Permissions.Register(permission);
		}
	}
	
	public static partial class Sites
	{
		/// <summary>
		/// 资源代码。
		/// </summary>
		internal const string ResourceCode = "SiteManage";

		/// <summary>
		/// 资源标识。
		/// </summary>
		internal readonly static Guid ResourceId = new Guid("062FAD92-F362-49C9-8F3A-9AE7E5AB273D");

		/// <summary>
		/// 资源名称。
		/// </summary>
		internal const string ResourceName = "站点管理";

		/// <summary>
		/// 资源描述。
		/// </summary>
		internal const string ResourceDescription = "";

		/// <summary>
		/// 权限码
		/// </summary>
		public enum PermissionCode
		{
			Insert = 3,
			Update = 7,
			Delete = 15,
		}

		/// <summary>
		/// 注册权限。
		/// </summary>
		internal static void RegisterPermissions()
		{
			ResourceCategories.RegisterSystemManage();
			RegisterCategoryResource();
			RegisterResourcePermissions();
		}

		/// <summary>
		/// 注册资源类别下的资源。
		/// </summary>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterCategoryResource()
		{
			Resource resource = new Resource();
			resource.CategoryId = ResourceCategories.SystemManageResourceCategoryId;
			resource.ResourceId = ResourceId;
			resource.ResourceCode = ResourceCode;
			resource.ResourceName = ResourceName;
			resource.Description = ResourceDescription;

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册资源下的权限。
		/// </summary>
		private static void RegisterResourcePermissions()
		{
			Permission permission;

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Insert;
			permission.PermissionName = "添加";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Update;
			permission.PermissionName = "修改";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Delete;
			permission.PermissionName = "删除";
			permission.Description = "";
			Permissions.Register(permission);
		}
	}
	
	public static partial class PageBlocks
	{
		/// <summary>
		/// 资源代码。
		/// </summary>
		internal const string ResourceCode = "PageBlockManage";

		/// <summary>
		/// 资源标识。
		/// </summary>
		internal readonly static Guid ResourceId = new Guid("0091AC7F-1B2B-4C18-A159-4C173FB9E339");

		/// <summary>
		/// 资源名称。
		/// </summary>
		internal const string ResourceName = "页面块管理";

		/// <summary>
		/// 资源描述。
		/// </summary>
		internal const string ResourceDescription = "";

		/// <summary>
		/// 权限码
		/// </summary>
		public enum PermissionCode
		{
			Insert = 3,
			Update = 7,
			Delete = 15,
		}

		/// <summary>
		/// 注册权限。
		/// </summary>
		internal static void RegisterPermissions()
		{
			ResourceCategories.RegisterSystemManage();
			RegisterCategoryResource();
			RegisterResourcePermissions();
		}

		/// <summary>
		/// 注册资源类别下的资源。
		/// </summary>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterCategoryResource()
		{
			Resource resource = new Resource();
			resource.CategoryId = ResourceCategories.SystemManageResourceCategoryId;
			resource.ResourceId = ResourceId;
			resource.ResourceCode = ResourceCode;
			resource.ResourceName = ResourceName;
			resource.Description = ResourceDescription;

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册资源下的权限。
		/// </summary>
		private static void RegisterResourcePermissions()
		{
			Permission permission;

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Insert;
			permission.PermissionName = "添加";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Update;
			permission.PermissionName = "修改";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Delete;
			permission.PermissionName = "删除";
			permission.Description = "";
			Permissions.Register(permission);
		}




		/// <summary>
		/// 块编辑资源类别代码
		/// </summary>
		internal const string BlockEditResourceCategoryCode = "PageBlockEdit";
		internal const string BlockEditResourceCategoryName = "块编辑";
		internal const string BlockEditResourceCategoryDescription = "";
		public static readonly Guid BlockEditResourceCategoryId = new Guid("E179913B-3453-4D8C-99F8-6AD3EC4BDDF8");

		/// <summary>
		/// 块编辑权限码
		/// </summary>
		public enum BlockEditPermissionCode
		{
			Edit = 7
		}

		/// <summary>
		/// 注册块编辑资源类别。
		/// </summary>
		/// <returns>注册的资源类别信息。</returns>
		private static ResourceCategory RegisterBlockEditResourceCategory()
		{
			ResourceCategory resourceCategory = new ResourceCategory();
			resourceCategory.CategoryId = BlockEditResourceCategoryId;
			resourceCategory.CategoryName = BlockEditResourceCategoryName;
			resourceCategory.CategoryCode = BlockEditResourceCategoryCode;
			resourceCategory.Description = BlockEditResourceCategoryDescription;

			return ResourceCategories.Register(resourceCategory);
		}

		/// <summary>
		/// 注册块编辑类别的资源。
		/// </summary>
		/// <param name="site">资源所对应的站点。</param>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterBlockEditCategoryResource(Site site)
		{
			Resource resource = new Resource();
			resource.CategoryId = BlockEditResourceCategoryId;
			resource.ResourceId = Guid.NewGuid();
			resource.SiteId = site.SiteId;
			resource.ResourceName = site.SiteName;
			resource.Description = "";

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册块编辑类别的资源。
		/// </summary>
		/// <param name="parentResourceId">上级资源标识。</param>
		/// <param name="block">资源所对应的页面块。</param>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterBlockEditCategoryResource(Guid? parentResourceId, PageBlock block)
		{
			Resource resource = new Resource();
			resource.CategoryId = BlockEditResourceCategoryId;
			resource.ResourceId = Guid.NewGuid();
			resource.ParentResourceId = parentResourceId;
			resource.SiteId = block.SiteId;
			resource.ResourceCode = GetBlockEditResourceCode(block.BlockId);
			resource.ResourceName = block.Name;
			resource.Description = "";

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册权限。
		/// </summary>
		/// <param name="resourceId">所属资源标识。</param>
		private static void RegisterBlockEditResourcePermissions(Guid resourceId)
		{
			Permission permission;

			permission = new Permission();
			permission.ResourceId = resourceId;
			permission.PermissionCode = (int)BlockEditPermissionCode.Edit;
			permission.PermissionName = "编辑";
			permission.Description = "";
			Permissions.Register(permission);
		}

		/// <summary>
		/// 根据站点标识获取根资源标识。
		/// </summary>
		/// <param name="o">页面块集合对象。</param>
		/// <param name="siteId">站点的标识。</param>
		/// <returns>根资源标识。</returns>
		private static Guid? GetBlockEditRootResourceId(this System.Data.Linq.Table<PageBlock> o, int siteId)
		{
			return (o.Context as GenericModuleDataContext).Resources.GetIdentifier(BlockEditResourceCategoryId, siteId, null);
		}

		/// <summary>
		/// 根据块标识获取资源编码。
		/// </summary>
		/// <param name="blockId">块标识。</param>
		/// <returns>资源编码。</returns>
		private static string GetBlockEditResourceCode(int blockId)
		{
			return blockId.ToString();
		}

		/// <summary>
		/// 根据块标识获取资源标识。
		/// </summary>
		/// <param name="o">页面块集合对象。</param>
		/// <param name="blockId">块标识。</param>
		/// <returns>资源标识。</returns>
		private static Guid? GetBlockEditResourceId(this System.Data.Linq.Table<PageBlock> o, int blockId)
		{
			PageBlock block = o.GetItem(blockId);
			return GetBlockEditResourceId(o, block);
		}

		/// <summary>
		/// 根据块获取资源标识。
		/// </summary>
		/// <param name="o">页面块集合对象。</param>
		/// <param name="block">块。</param>
		/// <returns>资源标识。</returns>
		private static Guid? GetBlockEditResourceId(this System.Data.Linq.Table<PageBlock> o, PageBlock block)
		{
			if (block == null) return null;

			string resourceCode = GetBlockEditResourceCode(block.BlockId);
			return (o.Context as GenericModuleDataContext).Resources.GetIdentifier(BlockEditResourceCategoryId, block.SiteId, resourceCode);
		}

		/// <summary>
		/// 同步块编辑权限注册。
		/// </summary>
		public static void SyncBlockEditPermissionRegister()
		{
			GenericModuleDataContext dc = new GenericModuleDataContext();

			// 权限验证
			SystemInit.GetInitRight(dc, true);

			ResourceCategory resourceCategory = RegisterBlockEditResourceCategory();

			IEnumerable<Site> sites = dc.Sites.AsEnumerable();
			foreach (Site site in sites)
			{
				// 注册资源
				Resource resource = RegisterBlockEditCategoryResource(site);

				// 注册权限
				RegisterBlockEditResourcePermissions(resource.ResourceId);

				SyncBlockEditPermissionRegister(dc, resource.ResourceId, site.SiteId);
			}
		}

		/// <summary>
		/// 块编辑权限注册。
		/// </summary>
		/// <param name="dc">数据容器。</param>
		/// <param name="parentResourceId">上级资源标识。</param>
		/// <param name="siteId">所属站点标识。</param>
		private static void SyncBlockEditPermissionRegister(GenericModuleDataContext dc, Guid? parentResourceId, int siteId)
		{
			IEnumerable<PageBlock> blocks = dc.PageBlocks.Where(p => p.SiteId == siteId).AsEnumerable();
			
			foreach (PageBlock block in blocks)
			{
				// 注册资源
				Resource resource = RegisterBlockEditCategoryResource(parentResourceId, block);

				// 注册权限
				RegisterBlockEditResourcePermissions(resource.ResourceId);
			}
		}

		/// <summary>
		/// 注册页面块的块编辑权限。
		/// </summary>
		/// <param name="block">要注册的页面块。</param>
		private static void RegisterPageBlockEditPermission(PageBlock block)
		{
			GenericModuleDataContext dc = new GenericModuleDataContext();

			ResourceCategory resourceCategory = RegisterBlockEditResourceCategory();

			Site site = dc.Sites.GetItem(block.SiteId);
			// 注册根资源
			Resource parentResource = RegisterBlockEditCategoryResource(site);
			// 注册根资源权限
			RegisterBlockEditResourcePermissions(parentResource.ResourceId);

			// 注册资源
			Resource resource = RegisterBlockEditCategoryResource(parentResource.ResourceId, block);
			// 注册资源权限
			RegisterBlockEditResourcePermissions(resource.ResourceId);
		}
	}
	
	public static partial class LinkClasses
	{
		/// <summary>
		/// 资源代码。
		/// </summary>
		internal const string ResourceCode = "LinkClassManage";

		/// <summary>
		/// 资源标识。
		/// </summary>
		internal readonly static Guid ResourceId = new Guid("EACA8D2D-CFCD-4E31-B3F1-A50C9CE42071");

		/// <summary>
		/// 资源名称。
		/// </summary>
		internal const string ResourceName = "链接类别管理";

		/// <summary>
		/// 资源描述。
		/// </summary>
		internal const string ResourceDescription = "";

		/// <summary>
		/// 权限码
		/// </summary>
		public enum PermissionCode
		{
			Insert = 3,
			Update = 7,
			Delete = 15,
		}

		/// <summary>
		/// 注册权限。
		/// </summary>
		internal static void RegisterPermissions()
		{
			ResourceCategories.RegisterSystemManage();
			RegisterCategoryResource();
			RegisterResourcePermissions();
		}

		/// <summary>
		/// 注册资源类别下的资源。
		/// </summary>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterCategoryResource()
		{
			Resource resource = new Resource();
			resource.CategoryId = ResourceCategories.SystemManageResourceCategoryId;
			resource.ResourceId = ResourceId;
			resource.ResourceCode = ResourceCode;
			resource.ResourceName = ResourceName;
			resource.Description = ResourceDescription;

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册资源下的权限。
		/// </summary>
		private static void RegisterResourcePermissions()
		{
			Permission permission;

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Insert;
			permission.PermissionName = "添加";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Update;
			permission.PermissionName = "修改";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Delete;
			permission.PermissionName = "删除";
			permission.Description = "";
			Permissions.Register(permission);
		}




		/// <summary>
		/// 链接资源类别代码
		/// </summary>
		public const string LinkReleaseResourceCategoryCode = "LinkRelease";
		public const string LinkReleaseResourceCategoryName = "链接发布";
		public const string LinkReleaseResourceCategoryDescription = "";
		public static readonly Guid LinkReleaseResourceCategoryId = new Guid("6C465416-EE5D-4A7D-8E9E-9740A5A0F9C8");

		/// <summary>
		/// 链接权限码
		/// </summary>
		public enum LinkReleasePermissionCode
		{
			Insert = 3,
			Update = 7,
			Delete = 15,
			Setting = 31,
		}

		/// <summary>
		/// 注册链接资源类别。
		/// </summary>
		/// <returns>注册的资源类别信息。</returns>
		private static ResourceCategory RegisterLinkReleaseResourceCategory()
		{
			ResourceCategory resourceCategory = new ResourceCategory();
			resourceCategory.CategoryId = LinkReleaseResourceCategoryId;
			resourceCategory.CategoryName = LinkReleaseResourceCategoryName;
			resourceCategory.CategoryCode = LinkReleaseResourceCategoryCode;
			resourceCategory.Description = LinkReleaseResourceCategoryDescription;

			return ResourceCategories.Register(resourceCategory);
		}

		/// <summary>
		/// 注册链接类别的资源。
		/// </summary>
		/// <param name="site">资源所对应的站点。</param>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterLinkReleaseCategoryResource(Site site)
		{
			Resource resource = new Resource();
			resource.CategoryId = LinkReleaseResourceCategoryId;
			resource.ResourceId = Guid.NewGuid();
			resource.SiteId = site.SiteId;
			resource.ResourceName = site.SiteName;
			resource.Description = "";

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册链接类别的资源。
		/// </summary>
		/// <param name="parentResourceId">上级资源标识。</param>
		/// <param name="linkClass">资源所对应的类别。</param>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterLinkReleaseCategoryResource(Guid? parentResourceId, LinkClass linkClass)
		{
			Resource resource = new Resource();
			resource.CategoryId = LinkReleaseResourceCategoryId;
			resource.ResourceId = Guid.NewGuid();
			resource.ParentResourceId = parentResourceId;
			resource.SiteId = linkClass.SiteId;
			resource.ResourceCode = GetLinkReleaseResourceCode(linkClass.ClassId);
			resource.ResourceName = linkClass.ClassName;
			resource.Description = "";

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册权限。
		/// </summary>
		/// <param name="resourceId">所属资源标识。</param>
		private static void RegisterLinkReleaseResourcePermissions(Guid resourceId)
		{
			Permission permission;

			permission = new Permission();
			permission.ResourceId = resourceId;
			permission.PermissionCode = (int)LinkReleasePermissionCode.Insert;
			permission.PermissionName = "添加";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = resourceId;
			permission.PermissionCode = (int)LinkReleasePermissionCode.Update;
			permission.PermissionName = "修改";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = resourceId;
			permission.PermissionCode = (int)LinkReleasePermissionCode.Delete;
			permission.PermissionName = "删除";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = resourceId;
			permission.PermissionCode = (int)LinkReleasePermissionCode.Setting;
			permission.PermissionName = "设置";
			permission.Description = "";
			Permissions.Register(permission);
		}



		/// <summary>
		/// 根据站点标识获取根资源标识。
		/// </summary>
		/// <param name="o">链接类别集合。</param>
		/// <param name="siteId">站点的标识。</param>
		/// <returns>根资源标识。</returns>
		public static Guid? GetLinkReleaseRootResourceId(this System.Data.Linq.Table<LinkClass> o, int siteId)
		{
			return (o.Context as GenericModuleDataContext).Resources.GetIdentifier(LinkReleaseResourceCategoryId, siteId, null);
		}

		/// <summary>
		/// 根据类别标识获取链接资源编码。
		/// </summary>
		/// <param name="classId">类别标识。</param>
		/// <returns>链接资源编码。</returns>
		private static string GetLinkReleaseResourceCode(int classId)
		{
			return classId.ToString();
		}

		/// <summary>
		/// 根据类别标识获取链接资源标识。
		/// </summary>
		/// <param name="o">链接类别集合。</param>
		/// <param name="classId">类别标识。</param>
		/// <returns>链接资源标识。</returns>
		internal static Guid? GetLinkReleaseResourceId(this System.Data.Linq.Table<LinkClass> o, int classId)
		{
			LinkClass linkClass = o.GetItem(classId);
			return GetLinkReleaseResourceId(o, linkClass);
		}

		/// <summary>
		/// 根据链接类别获取链接资源标识。
		/// </summary>
		/// <param name="o">链接类别集合。</param>
		/// <param name="linkClass">链接类别。</param>
		/// <returns>链接资源标识。</returns>
		internal static Guid? GetLinkReleaseResourceId(this System.Data.Linq.Table<LinkClass> o, LinkClass linkClass)
		{
			if (linkClass == null) return null;

			string resourceCode = GetLinkReleaseResourceCode(linkClass.ClassId);
			return (o.Context as GenericModuleDataContext).Resources.GetIdentifier(LinkReleaseResourceCategoryId, linkClass.SiteId, resourceCode);
		}

		/// <summary>
		/// 同步链接权限注册。
		/// </summary>
		public static void SyncLinkReleasePermissionRegister()
		{
			GenericModuleDataContext dc = new GenericModuleDataContext();

			// 权限验证
			SystemInit.GetInitRight(dc, true);

			ResourceCategory resourceCategory = RegisterLinkReleaseResourceCategory();

			IEnumerable<Site> sites = dc.Sites.AsEnumerable();
			foreach (Site site in sites)
			{
				// 注册资源
				Resource resource = RegisterLinkReleaseCategoryResource(site);

				// 注册权限
				RegisterLinkReleaseResourcePermissions(resource.ResourceId);

				SyncLinkReleasePermissionRegister(dc, resource.ResourceId, site.SiteId, null);
			}
		}

		/// <summary>
		/// 递归链接权限注册。
		/// </summary>
		/// <param name="dc">数据容器。</param>
		/// <param name="parentResourceId">上级资源标识。</param>
		/// <param name="siteID">所属站点标识。</param>
		/// <param name="pClassID">上级模块标识。</param>
		private static void SyncLinkReleasePermissionRegister(GenericModuleDataContext dc, Guid? parentResourceId, int siteId, int? pClassId)
		{
			var linkClasses = dc.LinkClasses.GetChildren(siteId, pClassId);

			foreach (LinkClass linkClass in linkClasses)
			{
				// 注册资源
				Resource resource = RegisterLinkReleaseCategoryResource(parentResourceId, linkClass);

				// 注册权限
				RegisterLinkReleaseResourcePermissions(resource.ResourceId);

				SyncLinkReleasePermissionRegister(dc, resource.ResourceId, siteId, linkClass.ClassId);
			}
		}

		/// <summary>
		/// 注册链接类别链接权限。
		/// </summary>
		/// <param name="linkClass">要注册的链接类别。</param>
		private static void RegisterLinkClassLinkReleasePermission(LinkClass linkClass)
		{
			GenericModuleDataContext dc = new GenericModuleDataContext();

			ResourceCategory resourceCategory = RegisterLinkReleaseResourceCategory();

			Resource parentResource;
			if (linkClass.PClassId != null)
			{
				parentResource = dc.Resources.GetItem(LinkReleaseResourceCategoryId, linkClass.SiteId, GetLinkReleaseResourceCode(linkClass.PClassId.Value));
			}
			else
			{
				Site site = dc.Sites.GetItem(linkClass.SiteId);
				parentResource = RegisterLinkReleaseCategoryResource(site);
			}

			if (parentResource == null)
				throw new ObjectNotExistsException(Res.Resources_NotExistsResource);

			// 注册资源
			Resource resource = RegisterLinkReleaseCategoryResource(parentResource.ResourceId, linkClass);

			// 注册权限
			RegisterLinkReleaseResourcePermissions(resource.ResourceId);
		}
	}
		
	public static partial class Modules
	{
		/// <summary>
		/// 资源代码。
		/// </summary>
		internal const string ResourceCode = "ModuleManage";

		/// <summary>
		/// 资源标识。
		/// </summary>
		internal readonly static Guid ResourceId = new Guid("6CCA3B70-EA21-4255-B111-044A3DF45BAB");

		/// <summary>
		/// 资源名称。
		/// </summary>
		internal const string ResourceName = "模块管理";

		/// <summary>
		/// 资源描述。
		/// </summary>
		internal const string ResourceDescription = "";

		/// <summary>
		/// 权限码
		/// </summary>
		public enum PermissionCode
		{
			Insert = 3,
			Update = 7,
			Delete = 15,
		}

		/// <summary>
		/// 注册权限。
		/// </summary>
		internal static void RegisterPermissions()
		{
			ResourceCategories.RegisterSystemManage();
			RegisterCategoryResource();
			RegisterResourcePermissions();
		}

		/// <summary>
		/// 注册资源类别下的资源。
		/// </summary>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterCategoryResource()
		{
			Resource resource = new Resource();
			resource.CategoryId = ResourceCategories.SystemManageResourceCategoryId;
			resource.ResourceId = ResourceId;
			resource.ResourceCode = ResourceCode;
			resource.ResourceName = ResourceName;
			resource.Description = ResourceDescription;

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册资源下的权限。
		/// </summary>
		private static void RegisterResourcePermissions()
		{
			Permission permission;

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Insert;
			permission.PermissionName = "添加";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Update;
			permission.PermissionName = "修改";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Delete;
			permission.PermissionName = "删除";
			permission.Description = "";
			Permissions.Register(permission);
		}




		/// <summary>
		/// 文章资源模块代码
		/// </summary>
		public const string ArticleReleaseResourceCategoryCode = "ArticleRelease";
		public const string ArticleReleaseResourceCategoryName = "文章发布";
		public const string ArticleReleaseResourceCategoryDescription = "";
		public static readonly Guid ArticleReleaseResourceCategoryId = new Guid("594125AF-F61F-47F8-AB81-B84D2820EE10");

		/// <summary>
		/// 文章权限码
		/// </summary>
		public enum ArticleReleasePermissionCode
		{
			Read = 1,
			Release = 3,
			Remove = 15,
			Setting = 31
		}

		/// <summary>
		/// 注册文章资源模块。
		/// </summary>
		/// <returns>注册的资源模块信息。</returns>
		private static ResourceCategory RegisterArticleReleaseResourceCategory()
		{
			ResourceCategory resourceCategory = new ResourceCategory();
			resourceCategory.CategoryId = ArticleReleaseResourceCategoryId;
			resourceCategory.CategoryName = ArticleReleaseResourceCategoryName;
			resourceCategory.CategoryCode = ArticleReleaseResourceCategoryCode;
			resourceCategory.Description = ArticleReleaseResourceCategoryDescription;

			return ResourceCategories.Register(resourceCategory);
		}

		/// <summary>
		/// 注册文章模块的资源。
		/// </summary>
		/// <param name="site">资源所对应的站点。</param>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterArticleReleaseCategoryResource(Site site)
		{
			Resource resource = new Resource();
			resource.CategoryId = ArticleReleaseResourceCategoryId;
			resource.ResourceId = Guid.NewGuid();
			resource.SiteId = site.SiteId;
			resource.ResourceName = site.SiteName;
			resource.Description = "";

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册文章模块的资源。
		/// </summary>
		/// <param name="parentResourceId">上级资源标识。</param>
		/// <param name="module">资源所对应的模块。</param>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterArticleReleaseCategoryResource(Guid? parentResourceId, Module module)
		{
			Resource resource = new Resource();
			resource.CategoryId = ArticleReleaseResourceCategoryId;
			resource.ResourceId = Guid.NewGuid();
			resource.ParentResourceId = parentResourceId;
			resource.SiteId = module.SiteId;
			resource.ResourceCode = GetArticleReleaseResourceCode(module.ModuleId);
			resource.ResourceName = module.ModuleName;
			resource.Description = "";

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册权限。
		/// </summary>
		/// <param name="resourceId">所属资源标识。</param>
		private static void RegisterArticleReleaseResourcePermissions(Guid resourceId)
		{
			Permission permission;

			permission = new Permission();
			permission.ResourceId = resourceId;
			permission.PermissionCode = (int)ArticleReleasePermissionCode.Read;
			permission.PermissionName = "阅读";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = resourceId;
			permission.PermissionCode = (int)ArticleReleasePermissionCode.Release;
			permission.PermissionName = "发布";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = resourceId;
			permission.PermissionCode = (int)ArticleReleasePermissionCode.Remove;
			permission.PermissionName = "移除";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = resourceId;
			permission.PermissionCode = (int)ArticleReleasePermissionCode.Setting;
			permission.PermissionName = "设置";
			permission.Description = "";
			Permissions.Register(permission);
		}



		/// <summary>
		/// 根据站点标识获取根资源标识。
		/// </summary>
		/// <param name="o">文章模块集合。</param>
		/// <param name="siteId">站点的标识。</param>
		/// <returns>根资源标识。</returns>
		public static Guid? GetArticleReleaseRootResourceId(this System.Data.Linq.Table<Module> o, int siteId)
		{
			return (o.Context as GenericModuleDataContext).Resources.GetIdentifier(ArticleReleaseResourceCategoryId, siteId, null);
		}

		/// <summary>
		/// 根据模块标识获取文章资源编码。
		/// </summary>
		/// <param name="moduleId">模块标识。</param>
		/// <returns>文章资源编码。</returns>
		public static string GetArticleReleaseResourceCode(int moduleId)
		{
			return moduleId.ToString();
		}

		/// <summary>
		/// 根据模块标识获取文章资源标识。
		/// </summary>
		/// <param name="o">文章模块集合。</param>
		/// <param name="moduleId">模块标识。</param>
		/// <returns>文章资源标识。</returns>
		internal static Guid? GetArticleReleaseResourceId(this System.Data.Linq.Table<Module> o, int moduleId)
		{
			Module module = o.GetItem(moduleId);
			return GetArticleReleaseResourceId(o, module);
		}

		/// <summary>
		/// 根据文章模块获取文章资源标识。
		/// </summary>
		/// <param name="o">文章模块集合。</param>
		/// <param name="module">文章模块。</param>
		/// <returns>文章资源标识。</returns>
		internal static Guid? GetArticleReleaseResourceId(this System.Data.Linq.Table<Module> o, Module module)
		{
			if (module == null) return null;

			string resourceCode = GetArticleReleaseResourceCode(module.ModuleId);
			return (o.Context as GenericModuleDataContext).Resources.GetIdentifier(ArticleReleaseResourceCategoryId, module.SiteId, resourceCode);
		}

		/// <summary>
		/// 同步文章权限注册。
		/// </summary>
		public static void SyncArticleReleasePermissionRegister()
		{
			GenericModuleDataContext dc = new GenericModuleDataContext();

			// 权限验证
			SystemInit.GetInitRight(dc, true);

			ResourceCategory resourceCategory = RegisterArticleReleaseResourceCategory();

			IEnumerable<Site> sites = dc.Sites.AsEnumerable();
			foreach (Site site in sites)
			{
				// 注册资源
				Resource resource = RegisterArticleReleaseCategoryResource(site);

				// 注册权限
				RegisterArticleReleaseResourcePermissions(resource.ResourceId);

				SyncArticleReleasePermissionRegister(dc, resource.ResourceId, site.SiteId, null);
			}
		}

		/// <summary>
		/// 递归文章权限注册。
		/// </summary>
		/// <param name="dc">数据容器。</param>
		/// <param name="parentResourceId">上级资源标识。</param>
		/// <param name="siteID">所属站点标识。</param>
		/// <param name="pClassID">上级模块标识。</param>
		private static void SyncArticleReleasePermissionRegister(GenericModuleDataContext dc, Guid? parentResourceId, int siteId, int? pModuleId)
		{
			var modules = dc.Modules.GetChildren(siteId, pModuleId);

			foreach (var module in modules)
			{
				// 注册资源
				Resource resource = RegisterArticleReleaseCategoryResource(parentResourceId, module);

				// 注册权限
				RegisterArticleReleaseResourcePermissions(resource.ResourceId);

				SyncArticleReleasePermissionRegister(dc, resource.ResourceId, siteId, module.ModuleId);
			}
		}

		/// <summary>
		/// 注册文章模块文章权限。
		/// </summary>
		/// <param name="module">要注册的文章模块。</param>
		private static void RegisterModuleArticleReleasePermission(Module module)
		{
			GenericModuleDataContext dc = new GenericModuleDataContext();

			ResourceCategory resourceCategory = RegisterArticleReleaseResourceCategory();

			Resource parentResource;
			if (module.PModuleId != null)
			{
				parentResource = dc.Resources.GetItem(ArticleReleaseResourceCategoryId, module.SiteId, GetArticleReleaseResourceCode(module.PModuleId.Value));
			}
			else
			{
				Site site = dc.Sites.GetItem(module.SiteId);
				parentResource = RegisterArticleReleaseCategoryResource(site);
			}

			if (parentResource == null)
				throw new ObjectNotExistsException(Res.Resources_NotExistsResource);

			// 注册资源
			Resource resource = RegisterArticleReleaseCategoryResource(parentResource.ResourceId, module);

			// 注册权限
			RegisterArticleReleaseResourcePermissions(resource.ResourceId);
		}
	}
	
	public static partial class Articles
	{
		/// <summary>
		/// 资源代码。
		/// </summary>
		internal const string ResourceCode = "ArticleManage";

		/// <summary>
		/// 资源标识。
		/// </summary>
		internal readonly static Guid ResourceId = new Guid("FA737299-1B7D-4403-B271-A47634A65EFB");

		/// <summary>
		/// 资源名称。
		/// </summary>
		internal const string ResourceName = "文章库管理";

		/// <summary>
		/// 资源描述。
		/// </summary>
		internal const string ResourceDescription = "";

		/// <summary>
		/// 权限码
		/// </summary>
		public enum PermissionCode
		{
			Insert = 3,
			Update = 7,
			Delete = 15,
			Setting = 16,
			Statistics=32
		}

		/// <summary>
		/// 注册权限。
		/// </summary>
		internal static void RegisterPermissions()
		{
			ResourceCategories.RegisterSystemManage();
			RegisterCategoryResource();
			RegisterResourcePermissions();
		}

		/// <summary>
		/// 注册资源类别下的资源。
		/// </summary>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterCategoryResource()
		{
			Resource resource = new Resource();
			resource.CategoryId = ResourceCategories.SystemManageResourceCategoryId;
			resource.ResourceId = ResourceId;
			resource.ResourceCode = ResourceCode;
			resource.ResourceName = ResourceName;
			resource.Description = ResourceDescription;

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册资源下的权限。
		/// </summary>
		private static void RegisterResourcePermissions()
		{
			Permission permission;

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Insert;
			permission.PermissionName = "添加";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Update;
			permission.PermissionName = "修改";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Delete;
			permission.PermissionName = "删除";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Setting;
			permission.PermissionName = "设置";
			permission.Description = "";
			Permissions.Register(permission);


			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Statistics;
			permission.PermissionName = "统计";
			permission.Description = "";
			Permissions.Register(permission);


		}
	}
	
	public static partial class VoteClasses
	{
		/// <summary>
		/// 资源代码。
		/// </summary>
		internal const string ResourceCode = "VoteClassManage";

		/// <summary>
		/// 资源标识。
		/// </summary>
		internal readonly static Guid ResourceId = new Guid("E98B5B91-1585-4B60-9DD3-E37E155E7509");

		/// <summary>
		/// 资源名称。
		/// </summary>
		internal const string ResourceName = "投票类别管理";

		/// <summary>
		/// 资源描述。
		/// </summary>
		internal const string ResourceDescription = "";

		/// <summary>
		/// 权限码
		/// </summary>
		public enum PermissionCode
		{
			Insert = 3,
			Update = 7,
			Delete = 15,
		}

		/// <summary>
		/// 注册权限。
		/// </summary>
		internal static void RegisterPermissions()
		{
			ResourceCategories.RegisterSystemManage();
			RegisterCategoryResource();
			RegisterResourcePermissions();
		}

		/// <summary>
		/// 注册资源类别下的资源。
		/// </summary>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterCategoryResource()
		{
			Resource resource = new Resource();
			resource.CategoryId = ResourceCategories.SystemManageResourceCategoryId;
			resource.ResourceId = ResourceId;
			resource.ResourceCode = ResourceCode;
			resource.ResourceName = ResourceName;
			resource.Description = ResourceDescription;

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册资源下的权限。
		/// </summary>
		private static void RegisterResourcePermissions()
		{
			Permission permission;

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Insert;
			permission.PermissionName = "添加";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Update;
			permission.PermissionName = "修改";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Delete;
			permission.PermissionName = "删除";
			permission.Description = "";
			Permissions.Register(permission);
		}




		/// <summary>
		/// 调查资源类别代码
		/// </summary>
		public const string VoteReleaseResourceCategoryCode = "VoteRelease";
		public const string VoteReleaseResourceCategoryName = "调查发布";
		public const string VoteReleaseResourceCategoryDescription = "";
		public static readonly Guid VoteReleaseResourceCategoryId = new Guid("a64a8c7a-e3e2-4103-a344-a48f728d5abc");

		/// <summary>
		/// 调查权限码
		/// </summary>
		public enum VoteReleasePermissionCode
		{
			Insert = 3,
			Update = 7,
			Delete = 15,
			Setting = 31,
			Vote = 1024
		}

		/// <summary>
		/// 注册调查资源类别。
		/// </summary>
		/// <returns>注册的资源类别信息。</returns>
		private static ResourceCategory RegisterVoteReleaseResourceCategory()
		{
			ResourceCategory resourceCategory = new ResourceCategory();
			resourceCategory.CategoryId = VoteReleaseResourceCategoryId;
			resourceCategory.CategoryName = VoteReleaseResourceCategoryName;
			resourceCategory.CategoryCode = VoteReleaseResourceCategoryCode;
			resourceCategory.Description = VoteReleaseResourceCategoryDescription;

			return ResourceCategories.Register(resourceCategory);
		}

		/// <summary>
		/// 注册调查类别的资源。
		/// </summary>
		/// <param name="site">资源所对应的站点。</param>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterVoteReleaseCategoryResource(Site site)
		{
			Resource resource = new Resource();
			resource.CategoryId = VoteReleaseResourceCategoryId;
			resource.ResourceId = Guid.NewGuid();
			resource.SiteId = site.SiteId;
			resource.ResourceName = site.SiteName;
			resource.Description = "";

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册调查类别的资源。
		/// </summary>
		/// <param name="parentResourceId">上级资源标识。</param>
		/// <param name="voteClass">资源所对应的类别。</param>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterVoteReleaseCategoryResource(Guid? parentResourceId, VoteClass voteClass)
		{
			Resource resource = new Resource();
			resource.CategoryId = VoteReleaseResourceCategoryId;
			resource.ResourceId = Guid.NewGuid();
			resource.ParentResourceId = parentResourceId;
			resource.SiteId = voteClass.SiteId;
			resource.ResourceCode = GetVoteReleaseResourceCode(voteClass.ClassId);
			resource.ResourceName = voteClass.ClassName;
			resource.Description = "";

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册权限。
		/// </summary>
		/// <param name="resourceId">所属资源标识。</param>
		private static void RegisterVoteReleaseResourcePermissions(Guid resourceId)
		{
			Permission permission;

			permission = new Permission();
			permission.ResourceId = resourceId;
			permission.PermissionCode = (int)VoteReleasePermissionCode.Insert;
			permission.PermissionName = "添加";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = resourceId;
			permission.PermissionCode = (int)VoteReleasePermissionCode.Update;
			permission.PermissionName = "修改";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = resourceId;
			permission.PermissionCode = (int)VoteReleasePermissionCode.Delete;
			permission.PermissionName = "删除";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = resourceId;
			permission.PermissionCode = (int)VoteReleasePermissionCode.Setting;
			permission.PermissionName = "设置";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = resourceId;
			permission.PermissionCode = (int)VoteReleasePermissionCode.Vote;
			permission.PermissionName = "参与调查";
			permission.Description = "";
			Permissions.Register(permission);
		}



		/// <summary>
		/// 根据站点标识获取根资源标识。
		/// </summary>
		/// <param name="o">调查类别集合。</param>
		/// <param name="siteId">站点的标识。</param>
		/// <returns>根资源标识。</returns>
		public static Guid? GetVoteReleaseRootResourceId(this System.Data.Linq.Table<VoteClass> o, int siteId)
		{
			return (o.Context as GenericModuleDataContext).Resources.GetIdentifier(VoteReleaseResourceCategoryId, siteId, null);
		}
		
		/// <summary>
		/// 根据类别标识获取调查资源编码。
		/// </summary>
		/// <param name="classId">类别标识。</param>
		/// <returns>调查资源编码。</returns>
		private static string GetVoteReleaseResourceCode(int classId)
		{
			return classId.ToString();
		}

		/// <summary>
		/// 根据类别标识获取调查资源标识。
		/// </summary>
		/// <param name="o">调查类别集合。</param>
		/// <param name="classId">类别标识。</param>
		/// <returns>调查资源标识。</returns>
		internal static Guid? GetVoteReleaseResourceId(this System.Data.Linq.Table<VoteClass> o, int classId)
		{
			VoteClass voteClass = o.GetItem(classId);
			return GetVoteReleaseResourceId(o, voteClass);
		}

		/// <summary>
		/// 根据调查类别获取调查资源标识。
		/// </summary>
		/// <param name="o">调查类别集合。</param>
		/// <param name="voteClass">调查类别。</param>
		/// <returns>调查资源标识。</returns>
		internal static Guid? GetVoteReleaseResourceId(this System.Data.Linq.Table<VoteClass> o, VoteClass voteClass)
		{
			if (voteClass == null) return null;

			string resourceCode = GetVoteReleaseResourceCode(voteClass.ClassId);
			return (o.Context as GenericModuleDataContext).Resources.GetIdentifier(VoteReleaseResourceCategoryId, voteClass.SiteId, resourceCode);
		}

		/// <summary>
		/// 同步调查权限注册。
		/// </summary>
		public static void SyncVoteReleasePermissionRegister()
		{
			GenericModuleDataContext dc = new GenericModuleDataContext();

			// 权限验证
			SystemInit.GetInitRight(dc, true);

			ResourceCategory resourceCategory = RegisterVoteReleaseResourceCategory();

			IEnumerable<Site> sites = dc.Sites.AsEnumerable();
			foreach (Site site in sites)
			{
				// 注册资源
				Resource resource = RegisterVoteReleaseCategoryResource(site);

				// 注册权限
				RegisterVoteReleaseResourcePermissions(resource.ResourceId);

				SyncVoteReleasePermissionRegister(dc, resource.ResourceId, site.SiteId, null);
			}
		}

		/// <summary>
		/// 递归调查权限注册。
		/// </summary>
		/// <param name="dc">数据容器。</param>
		/// <param name="parentResourceId">上级资源标识。</param>
		/// <param name="siteId">所属站点标识。</param>
		/// <param name="pClassId">上级模块标识。</param>
		private static void SyncVoteReleasePermissionRegister(GenericModuleDataContext dc, Guid? parentResourceId, int siteId, int? pClassId)
		{
			var voteClasses = dc.VoteClasses.GetChildren(siteId, pClassId);

			foreach (VoteClass voteClass in voteClasses)
			{
				// 注册资源
				Resource resource = RegisterVoteReleaseCategoryResource(parentResourceId, voteClass);

				// 注册权限
				RegisterVoteReleaseResourcePermissions(resource.ResourceId);

				SyncVoteReleasePermissionRegister(dc, resource.ResourceId, siteId, voteClass.ClassId);
			}
		}

		/// <summary>
		/// 注册调查类别调查权限。
		/// </summary>
		/// <param name="voteClass">要注册的调查类别。</param>
		private static void RegisterVoteClassVoteReleasePermission(VoteClass voteClass)
		{
			GenericModuleDataContext dc = new GenericModuleDataContext();

			ResourceCategory resourceCategory = RegisterVoteReleaseResourceCategory();

			Resource parentResource;
			if (voteClass.PClassId != null)
			{
				parentResource = dc.Resources.GetItem(VoteReleaseResourceCategoryId, voteClass.SiteId, GetVoteReleaseResourceCode(voteClass.PClassId.Value));
			}
			else
			{
				Site site = dc.Sites.GetItem(voteClass.SiteId);
				parentResource = RegisterVoteReleaseCategoryResource(site);
			}

			if (parentResource == null)
				throw new ObjectNotExistsException(Res.Resources_NotExistsResource);

			// 注册资源
			Resource resource = RegisterVoteReleaseCategoryResource(parentResource.ResourceId, voteClass);

			// 注册权限
			RegisterVoteReleaseResourcePermissions(resource.ResourceId);
		}
	}
	
	public static partial class MessageBoards
	{
		/// <summary>
		/// 资源代码。
		/// </summary>
		internal const string ResourceCode = "MessageBoardManage";

		/// <summary>
		/// 资源标识。
		/// </summary>
		internal readonly static Guid ResourceId = new Guid("67D4B73C-9544-44B6-BBA7-ED99BDCA0A19");

		/// <summary>
		/// 资源名称。
		/// </summary>
		internal const string ResourceName = "留言管理";

		/// <summary>
		/// 资源描述。
		/// </summary>
		internal const string ResourceDescription = "";

		/// <summary>
		/// 权限码
		/// </summary>
		public enum PermissionCode
		{
			Post = 3,
			Reply = 7,
			Delete = 15,
			Setting = 31
		}

		/// <summary>
		/// 注册权限。
		/// </summary>
		internal static void RegisterPermissions()
		{
			ResourceCategories.RegisterSystemManage();
			RegisterCategoryResource();
			RegisterResourcePermissions();
		}

		/// <summary>
		/// 注册资源类别下的资源。
		/// </summary>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterCategoryResource()
		{
			Resource resource = new Resource();
			resource.CategoryId = ResourceCategories.SystemManageResourceCategoryId;
			resource.ResourceId = ResourceId;
			resource.ResourceCode = ResourceCode;
			resource.ResourceName = ResourceName;
			resource.Description = ResourceDescription;

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册资源下的权限。
		/// </summary>
		private static void RegisterResourcePermissions()
		{
			Permission permission;

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Post;
			permission.PermissionName = "发表留言";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Reply;
			permission.PermissionName = "答复";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Delete;
			permission.PermissionName = "删除";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Setting;
			permission.PermissionName = "设置";
			permission.Description = "";
			Permissions.Register(permission);
		}
	}
	
	public static partial class Comments
	{
		/// <summary>
		/// 资源代码。
		/// </summary>
		internal const string ResourceCode = "CommentManage";

		/// <summary>
		/// 资源标识。
		/// </summary>
		internal readonly static Guid ResourceId = new Guid("BFAE444E-1276-4670-BD3C-53189522269A");

		/// <summary>
		/// 资源名称。
		/// </summary>
		internal const string ResourceName = "评论管理";

		/// <summary>
		/// 资源描述。
		/// </summary>
		internal const string ResourceDescription = "";

		/// <summary>
		/// 权限码
		/// </summary>
		public enum PermissionCode
		{
			Post = 3,
			Update = 7,
			Delete = 15,
			Setting = 31
		}

		/// <summary>
		/// 注册权限。
		/// </summary>
		internal static void RegisterPermissions()
		{
			ResourceCategories.RegisterSystemManage();
			RegisterCategoryResource();
			RegisterResourcePermissions();
		}

		/// <summary>
		/// 注册资源类别下的资源。
		/// </summary>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterCategoryResource()
		{
			Resource resource = new Resource();
			resource.CategoryId = ResourceCategories.SystemManageResourceCategoryId;
			resource.ResourceId = ResourceId;
			resource.ResourceCode = ResourceCode;
			resource.ResourceName = ResourceName;
			resource.Description = ResourceDescription;

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册资源下的权限。
		/// </summary>
		private static void RegisterResourcePermissions()
		{
			Permission permission;

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Post;
			permission.PermissionName = "发表评论";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Update;
			permission.PermissionName = "修改";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Delete;
			permission.PermissionName = "删除";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Setting;
			permission.PermissionName = "设置";
			permission.Description = "";
			Permissions.Register(permission);
		}
	}
	
	public static partial class FeedBacks
	{
		/// <summary>
		/// 资源代码。
		/// </summary>
		internal const string ResourceCode = "FeedBackManage";

		/// <summary>
		/// 资源标识。
		/// </summary>
		internal readonly static Guid ResourceId = new Guid("986013FA-B61F-4B3F-814B-78229142DAE9");

		/// <summary>
		/// 资源名称。
		/// </summary>
		internal const string ResourceName = "反馈管理";

		/// <summary>
		/// 资源描述。
		/// </summary>
		internal const string ResourceDescription = "";

		/// <summary>
		/// 权限码
		/// </summary>
		public enum PermissionCode
		{
			Post = 3,
			Delete = 15,
		}

		/// <summary>
		/// 注册权限。
		/// </summary>
		internal static void RegisterPermissions()
		{
			ResourceCategories.RegisterSystemManage();
			RegisterCategoryResource();
			RegisterResourcePermissions();
		}

		/// <summary>
		/// 注册资源类别下的资源。
		/// </summary>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterCategoryResource()
		{
			Resource resource = new Resource();
			resource.CategoryId = ResourceCategories.SystemManageResourceCategoryId;
			resource.ResourceId = ResourceId;
			resource.ResourceCode = ResourceCode;
			resource.ResourceName = ResourceName;
			resource.Description = ResourceDescription;

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册资源下的权限。
		/// </summary>
		private static void RegisterResourcePermissions()
		{
			Permission permission;

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Post;
			permission.PermissionName = "提交反馈";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Delete;
			permission.PermissionName = "删除";
			permission.Description = "";
			Permissions.Register(permission);
		}
	}
	
	public static partial class SqlCacheDependency
	{
		/// <summary>
		/// 资源代码。
		/// </summary>
		internal const string ResourceCode = "CacheDependencyManage";

		/// <summary>
		/// 资源标识。
		/// </summary>
		internal readonly static Guid ResourceId = new Guid("A856F5BB-37C2-4B82-A1AD-C15468B241CE");

		/// <summary>
		/// 资源名称。
		/// </summary>
		internal const string ResourceName = "缓存通知管理";

		/// <summary>
		/// 资源描述。
		/// </summary>
		internal const string ResourceDescription = "";

		/// <summary>
		/// 权限码
		/// </summary>
		public enum PermissionCode
		{
			Manage = 1
		}

		/// <summary>
		/// 注册权限。
		/// </summary>
		internal static void RegisterPermissions()
		{
			ResourceCategories.RegisterSystemManage();
			RegisterCategoryResource();
			RegisterResourcePermissions();
		}

		/// <summary>
		/// 注册资源类别下的资源。
		/// </summary>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterCategoryResource()
		{
			Resource resource = new Resource();
			resource.CategoryId = ResourceCategories.SystemManageResourceCategoryId;
			resource.ResourceId = ResourceId;
			resource.ResourceCode = ResourceCode;
			resource.ResourceName = ResourceName;
			resource.Description = ResourceDescription;

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册资源下的权限。
		/// </summary>
		private static void RegisterResourcePermissions()
		{
			Permission permission;

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Manage;
			permission.PermissionName = "管理";
			permission.Description = "";
			Permissions.Register(permission);
		}
	}
	
	public static partial class OverallControl
	{
		/// <summary>
		/// 资源代码。
		/// </summary>
		internal const string ResourceCode = "OverallControl";

		/// <summary>
		/// 资源标识。
		/// </summary>
		internal readonly static Guid ResourceId = new Guid("b59caefd-3baf-4c1a-a39c-249372a13f7b");

		/// <summary>
		/// 资源名称。
		/// </summary>
		internal const string ResourceName = "全局控制";

		/// <summary>
		/// 资源描述。
		/// </summary>
		internal const string ResourceDescription = "";

		/// <summary>
		/// 权限码
		/// </summary>
		public enum PermissionCode
		{
			SkipReview = 1
		}

		/// <summary>
		/// 注册权限。
		/// </summary>
		internal static void RegisterPermissions()
		{
			ResourceCategories.RegisterSystemManage();
			RegisterCategoryResource();
			RegisterResourcePermissions();
		}

		/// <summary>
		/// 注册资源类别下的资源。
		/// </summary>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterCategoryResource()
		{
			Resource resource = new Resource();
			resource.CategoryId = ResourceCategories.SystemManageResourceCategoryId;
			resource.ResourceId = ResourceId;
			resource.ResourceCode = ResourceCode;
			resource.ResourceName = ResourceName;
			resource.Description = ResourceDescription;

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册资源下的权限。
		/// </summary>
		private static void RegisterResourcePermissions()
		{
			Permission permission;

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.SkipReview;
			permission.PermissionName = "跳过审核";
			permission.Description = "";
			Permissions.Register(permission);
		}



		#region GetSkipReviewRight
		/// <summary>
		/// 获取当前用户是否有跳过审核的权限。
		/// </summary>
		/// <param name="dc">数据容器。</param>
		/// <param name="info">操作的对象。</param>
		/// <param name="triggerException">当未通过权限验证的时候是否引发异常。</param>
		/// <returns>布尔值表示当前用户是否有跳过审核的权限。</returns>
		public static bool GetSkipReviewRight(GenericModuleDataContext dc, object info, bool triggerException)
		{
			string userName = Users.CurrentUserName;
			int permissionCode = (int)PermissionCode.SkipReview;
			bool b = dc.AccessController.GetUserIsHasPermission<object>(userName, info, ResourceId, permissionCode, Sites.CurrentSiteId);

			if (triggerException && !b)
				throw new PermissionException(userName, info, ResourceId, permissionCode, Res.PermissionExceptionMessage);
			return b;
		}

		/// <summary>
		/// 获取当前用户是否有跳过审核的权限。
		/// </summary>
		/// <param name="info">操作的对象。</param>
		/// <param name="triggerException">当未通过权限验证的时候是否引发异常。</param>
		/// <returns>布尔值表示当前用户是否有跳过审核的权限。</returns>
		public static bool GetSkipReviewRight(object info, bool triggerException)
		{
			return GetSkipReviewRight(new GenericModuleDataContext(), info, triggerException);
		}

		/// <summary>
		/// 获取当前用户是否有跳过审核的权限。
		/// </summary>
		/// <param name="info">操作的对象。</param>
		/// <returns>布尔值表示当前用户是否有跳过审核的权限。</returns>
		public static bool GetSkipReviewRight(object info)
		{
			return GetSkipReviewRight(info, false);
		}
		#endregion
	}
	
	public static partial class CachePages
	{
		/// <summary>
		/// 资源代码。
		/// </summary>
		internal const string ResourceCode = "CachePageManage";

		/// <summary>
		/// 资源标识。
		/// </summary>
		internal readonly static Guid ResourceId = new Guid("63368942-ce36-40aa-a298-357b990965a4");

		/// <summary>
		/// 资源名称。
		/// </summary>
		internal const string ResourceName = "缓存页管理";

		/// <summary>
		/// 资源描述。
		/// </summary>
		internal const string ResourceDescription = "";

		/// <summary>
		/// 权限码
		/// </summary>
		public enum PermissionCode
		{
			Insert = 3,
			Update = 7,
			Delete = 15
		}

		/// <summary>
		/// 注册权限。
		/// </summary>
		internal static void RegisterPermissions()
		{
			ResourceCategories.RegisterSystemManage();
			RegisterCategoryResource();
			RegisterResourcePermissions();
		}

		/// <summary>
		/// 注册资源类别下的资源。
		/// </summary>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterCategoryResource()
		{
			Resource resource = new Resource();
			resource.CategoryId = ResourceCategories.SystemManageResourceCategoryId;
			resource.ResourceId = ResourceId;
			resource.ResourceCode = ResourceCode;
			resource.ResourceName = ResourceName;
			resource.Description = ResourceDescription;

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册资源下的权限。
		/// </summary>
		private static void RegisterResourcePermissions()
		{
			Permission permission;

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Insert;
			permission.PermissionName = "添加";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Update;
			permission.PermissionName = "修改";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Delete;
			permission.PermissionName = "删除";
			permission.Description = "";
			Permissions.Register(permission);
		}
	}

	public static partial class KeywordForLinks
	{
		/// <summary>
		/// 资源代码。
		/// </summary>
		internal const string ResourceCode = "KeywordForLinksManage";

		/// <summary>
		/// 资源标识。
		/// </summary>
		internal readonly static Guid ResourceId = new Guid("FF863A72-3DE9-434a-8F55-F9EC1BD5C7A3");

		/// <summary>
		/// 资源名称。
		/// </summary>
		internal const string ResourceName = "关键字链接";

		/// <summary>
		/// 资源描述。
		/// </summary>
		internal const string ResourceDescription = "";

		/// <summary>
		/// 权限码
		/// </summary>
		public enum PermissionCode
		{
			Insert = 3,
			Update = 7,
			Delete = 63
		}

		/// <summary>
		/// 注册权限。
		/// </summary>
		internal static void RegisterPermissions()
		{
			ResourceCategories.RegisterSystemManage();
			RegisterCategoryResource();
			RegisterResourcePermissions();
		}

		/// <summary>
		/// 注册资源类别下的资源。
		/// </summary>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterCategoryResource()
		{
			Resource resource = new Resource();
			resource.CategoryId = ResourceCategories.SystemManageResourceCategoryId;
			resource.ResourceId = ResourceId;
			resource.ResourceCode = ResourceCode;
			resource.ResourceName = ResourceName;
			resource.Description = ResourceDescription;

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册资源下的权限。
		/// </summary>
		private static void RegisterResourcePermissions()
		{
			Permission permission;

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Insert;
			permission.PermissionName = "添加";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Update;
			permission.PermissionName = "修改";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Delete;
			permission.PermissionName = "删除";
			permission.Description = "";
			Permissions.Register(permission);
		}
	}
	
	public static partial class Specials
	{
		/// <summary>
		/// 资源代码。
		/// </summary>
		internal const string ResourceCode = "SpecialManage";

		/// <summary>
		/// 资源标识。
		/// </summary>
		internal readonly static Guid ResourceId = new Guid("3f590b27-919a-451c-a037-83c59a59b5b7");

		/// <summary>
		/// 资源名称。
		/// </summary>
		internal const string ResourceName = "专题管理";

		/// <summary>
		/// 资源描述。
		/// </summary>
		internal const string ResourceDescription = "";

		/// <summary>
		/// 权限码
		/// </summary>
		public enum PermissionCode
		{
			Insert = 3,
			Update = 7,
			Delete = 15,
			Setting = 31
		}

		/// <summary>
		/// 注册权限。
		/// </summary>
		internal static void RegisterPermissions()
		{
			ResourceCategories.RegisterSystemManage();
			RegisterCategoryResource();
			RegisterResourcePermissions();
		}

		/// <summary>
		/// 注册资源类别下的资源。
		/// </summary>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterCategoryResource()
		{
			Resource resource = new Resource();
			resource.CategoryId = ResourceCategories.SystemManageResourceCategoryId;
			resource.ResourceId = ResourceId;
			resource.ResourceCode = ResourceCode;
			resource.ResourceName = ResourceName;
			resource.Description = ResourceDescription;

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册资源下的权限。
		/// </summary>
		private static void RegisterResourcePermissions()
		{
			Permission permission;

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Insert;
			permission.PermissionName = "添加";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Update;
			permission.PermissionName = "修改";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Setting;
			permission.PermissionName = "设置";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Delete;
			permission.PermissionName = "删除";
			permission.Description = "";
			Permissions.Register(permission);
		}
	}

	
	public static partial class TeamBlacks
	{
		/// <summary>
		/// 资源代码。
		/// </summary>
		internal const string ResourceCode = "TeamBlackManage";

		/// <summary>
		/// 资源标识。
		/// </summary>
		internal readonly static Guid ResourceId = new Guid("A23E4BC4-01A1-48f8-A4B2-DFB420B60D9F");

		/// <summary>
		/// 资源名称。
		/// </summary>
		internal const string ResourceName = "团队管理";

		/// <summary>
		/// 资源描述。
		/// </summary>
		internal const string ResourceDescription = "";

		/// <summary>
		/// 权限码
		/// </summary>
		public enum PermissionCode
		{
			Insert = 3,
			Update = 7,
			MarkDeleted = 15,
			Setting = 31,
			Delete = 63
		}

		/// <summary>
		/// 注册权限。
		/// </summary>
		internal static void RegisterPermissions()
		{
			ResourceCategories.RegisterSystemManage();
			RegisterCategoryResource();
			RegisterResourcePermissions();
		}

		/// <summary>
		/// 注册资源类别下的资源。
		/// </summary>
		/// <returns>注册的资源。</returns>
		private static Resource RegisterCategoryResource()
		{
			Resource resource = new Resource();
			resource.CategoryId = ResourceCategories.SystemManageResourceCategoryId;
			resource.ResourceId = ResourceId;
			resource.ResourceCode = ResourceCode;
			resource.ResourceName = ResourceName;
			resource.Description = ResourceDescription;

			return Resources.Register(resource);
		}

		/// <summary>
		/// 注册资源下的权限。
		/// </summary>
		private static void RegisterResourcePermissions()
		{
			Permission permission;

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Insert;
			permission.PermissionName = "添加";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Update;
			permission.PermissionName = "修改";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.MarkDeleted;
			permission.PermissionName = "标记删除";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Setting;
			permission.PermissionName = "设置";
			permission.Description = "";
			Permissions.Register(permission);

			permission = new Permission();
			permission.ResourceId = ResourceId;
			permission.PermissionCode = (int)PermissionCode.Delete;
			permission.PermissionName = "删除";
			permission.Description = "";
			Permissions.Register(permission);
		}
	}
	
}